﻿Public Class NhaCungCap
    Public Shared Function Them(ByVal TenNCC As String, ByVal DiaChi As String, ByVal DienThoai As String) As Boolean
        TenNCC = EscapeString(TenNCC)
        DiaChi = EscapeString(DiaChi)
        DienThoai = EscapeString(DienThoai)
        Return db.Query("INSERT INTO NhaCungCap(TenNCC,DiaChi,DienThoai) VALUES(N'" & TenNCC & "',N'" & DiaChi & "','" & DienThoai & "')")
    End Function
    Public Shared Function DanhSach() As DataTable
        Return db.QueryTable("SELECT * FROM NhaCungCap")
    End Function
    Public Shared Function CapNhat(ByVal MaNCC As String, ByVal TenNCC As String, ByVal DiaChi As String, ByVal DienThoai As String) As Boolean
        MaNCC = EscapeString(MaNCC)
        TenNCC = EscapeString(TenNCC)
        DiaChi = EscapeString(DiaChi)
        DienThoai = EscapeString(DienThoai)
        Return db.Query("UPDATE NhaCungCap SET TenNCC=N'" + TenNCC + "', DiaChi=N'" + DiaChi + "', DienThoai='" + DienThoai + "' WHERE MaNCC='" + MaNCC + "'")
    End Function
    Public Shared Function Xoa(ByVal MaNCC As String) As Boolean
        MaNCC = EscapeString(MaNCC)
        Return db.Query("DELETE FROM NhaCungCap WHERE MaNCC='" + MaNCC + "'")
    End Function
    Public Shared Function TimKiem(ByVal tukhoa As String) As DataTable
        tukhoa = EscapeString(tukhoa)
        Return db.QueryTable("SELECT * FROM NhaCungCap where MaNCC like N'%" + tukhoa + "%' or TenNCC like N'%" & tukhoa & "%' or DiaChi like N'%" & tukhoa & "%' or DienThoai like N'%" & tukhoa & "%'")
    End Function
End Class
